using System;

namespace IBNet
{
    /// <summary>
    /// An execution filter for use when requesting execution history from IB.
    /// </summary>
    public class ExecutionFilter
    {
        #region Private Fields

        private readonly string accountCode;
        private readonly int clientId;
        private readonly string exchange;
        private readonly SecurityType securityType;
        private readonly ActionSide actionSide;
        private readonly string symbol;
        private readonly DateTime time;

        #endregion

        #region Constructor

        /// <summary>
        /// Creates a new ExecutionFilter.
        /// </summary>
        /// <param name="clientId">Filter the results of the ReqExecutions() method based on the clientId.</param>
        /// <param name="acctCode">Filter the results of the ReqExecutions() method based on an account code.</param>
        /// <param name="time">Filter the results of the ReqExecutions() method based on execution reports received after the specified time.</param>
        /// <param name="symbol">Filter the results of the ReqExecutions() method based on the order symbol.</param>
        /// <param name="securityType">Refer to the Contract struct for the list of valid security types.</param>
        /// <param name="exchange">Filter the results of the ReqExecutions() method based on the order exchange.</param>
        /// <param name="actionSide">Filter the results of the ReqExecutions() method based on the order action.</param>
        public ExecutionFilter(int clientId, string acctCode, DateTime time, 
           string symbol, SecurityType securityType, string exchange, ActionSide actionSide)
        {
            this.clientId = clientId;
            this.accountCode = acctCode;
            this.time = time;
            this.symbol = symbol;
            this.securityType = securityType;
            this.exchange = exchange;
            this.actionSide = actionSide;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on the clientId.
        /// </summary>
        public int ClientId { get { return clientId; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on an account code.
        /// </summary>
        /// <remarks>This is only relevant for Financial Advisor (FA) accounts.</remarks>
        public string AccountCode { get { return accountCode; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on execution reports received after the specified time. 
        /// </summary>
        /// <remarks>The format for timeFilter is "yyyymmdd-hh:mm:ss"</remarks>
        public DateTime Time { get { return time; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on the order symbol.
        /// </summary>
        public string Symbol { get { return symbol; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on the order security type. 
        /// </summary>
        /// <remarks>Refer to the Contract struct for the list of valid security types.</remarks>
        public SecurityType SecurityType { get { return securityType; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on the order exchange.
        /// </summary>
        public string Exchange { get { return exchange; } }

        /// <summary>
        /// Filter the results of the ReqExecutions() method based on the order action. 
        /// </summary>
        /// <remarks>Refer to the Order struct for the list of valid order actions.</remarks>
        public ActionSide ActionSide { get { return actionSide; } }

        #endregion
    }
}